package com.modern.controller;

import com.modern.pojo.LoginInfo;
import com.modern.pojo.Result;
import com.modern.pojo.User;
import com.modern.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tjm84
 */
@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private UserService userService;
    @PostMapping
    public Result login(@RequestBody User user){
        LoginInfo result=userService.getLoginInfo(user);
        if(result!=null){
            return Result.success(result);
        }else {
            return Result.error("用户名或密码错误，请重新输入");
        }
    }

}
